package com.sx.first.action;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

@Controller
@Scope("prototype")
@Namespace("/download")
@Result(name = "download",type = "stream", params={"contentType","images/jpg","inputName","targetFile","contentDisposition","filename='${photoName}'","bufferSize","4096"})
public class DownloadAction extends ActionSupport {
	private String fileName;
	private String photoName;
	private String savePath = "E:/A1000phone/image/";
	private InputStream targetFile;

	@Action(value = "download")
	public String download() {
		try {
			targetFile = new FileInputStream(savePath + fileName);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return "download";
	}
	
	
	/*************************/
		
		
	public InputStream getTargetFile() {
		return targetFile;
	}

	public void setTargetFile(InputStream targetFile) {
		this.targetFile = targetFile;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getSavePath() {
		return savePath;
	}

	public void setSavePath(String savePath) {
		this.savePath = savePath;
	}
	
	public String getPhotoName() {
		return photoName;
	}

	public void setPhotoName(String photoName) {
		this.photoName = photoName;
	}

	
}
